home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / preservesinglequotes.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.0 KB  |  41 lines

  1. <!--- This example shows the use of preserveSingleQuotes --->
  2. <HTML>
  3.  
  4. <HEAD>
  5. <TITLE>
  6. PreserveSingleQuotes Example
  7. </TITLE>
  8. </HEAD>
  9.  
  10. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  11. <BODY  bgcolor="#FFFFD5">
  12.  
  13. <H3>PreserveSingleQuotes Example</H3>
  14.  
  15. <P>This is a useful function for creating lists of 
  16. information to return from a query.  In the following
  17. example, we pick the list of Centers in Suisun, San Francisco,
  18. and San Diego, using the SQL grammar IN to modify a WHERE
  19. clause rather than looping through the result set after
  20. the query is run.
  21.  
  22. <CFSET List = "'Suisun', 'San Francisco', 'San Diego'">
  23.  
  24. <CFQUERY NAME="GetCenters" DATASOURCE="cfsnippets">
  25.     SELECT Name, Address1, Address2, City, Phone
  26.     FROM Centers
  27.     WHERE City IN (#PreserveSingleQuotes(List)#)
  28. </CFQUERY>
  29.  
  30. <P>We found <CFOUTPUT>#GetCenters.RecordCount#</CFOUTPUT> records.
  31. <CFOUTPUT query="GetCenters">
  32. <P>#Name#<BR>    
  33. #Address1#<BR>
  34. <CFIF Address2 is not "">#Address2#</CFIF>
  35. #City#<BR>
  36. #Phone#<BR>
  37. </CFOUTPUT>
  38. </BODY>
  39.  
  40. </HTML>       
  41.